<template>
  <div class="tactical-loadouts-page">
    <!-- 页面标题栏 -->
    <div class="page-header">
      <div class="header-content">
        <div class="header-left">
          <div class="title-section">
            <n-icon size="28" class="title-icon">
              <svg viewBox="0 0 24 24">
                <path fill="currentColor" d="M12,2A10,10 0 0,1 22,12A10,10 0 0,1 12,22A10,10 0 0,1 2,12A10,10 0 0,1 12,2M12,4A8,8 0 0,0 4,12A8,8 0 0,0 12,20A8,8 0 0,0 20,12A8,8 0 0,0 12,4M12,6A6,6 0 0,1 18,12A6,6 0 0,1 12,18A6,6 0 0,1 6,12A6,6 0 0,1 12,6M12,8A4,4 0 0,0 8,12A4,4 0 0,0 12,16A4,4 0 0,0 16,12A4,4 0 0,0 12,8Z"/>
              </svg>
            </n-icon>
            <div class="title-text">
              <h1>战术装备推荐</h1>
              <p>智能配置 · 精准推荐 · 预算优化</p>
            </div>
          </div>
        </div>
        <div class="header-right">
          <div class="stats-grid">
            <div class="stat-item">
              <span class="stat-value">{{ totalLoadouts }}</span>
              <span class="stat-label">总配置</span>
            </div>
            <div class="stat-item">
              <span class="stat-value">{{ validLoadouts }}</span>
              <span class="stat-label">有效配置</span>
            </div>
            <div class="stat-item">
              <span class="stat-value">{{ Math.round(averageValue) }}</span>
              <span class="stat-label">平均价值</span>
            </div>
          </div>
        </div>
      </div>
    </div>

    <!-- 筛选控制栏 -->
    <div class="filter-panel">
      <n-card class="filter-card">
        <div class="filter-content">
          <div class="filter-left">
            <n-space :size="16" align="center">
              <div class="filter-item">
                <n-text class="filter-label">地图选择</n-text>
                <n-select
                  v-model:value="selectedMapId"
                  :options="mapOptions"
                  placeholder="选择地图"
                  :loading="mapsLoading"
                  clearable
                  size="medium"
                  style="width: 160px"
                  @update:value="handleMapChange"
                />
              </div>
              <div class="filter-item">
                <n-text class="filter-label">等级筛选</n-text>
                <n-select
                  v-model:value="selectedLevel"
                  :options="levelOptions"
                  placeholder="选择等级"
                  :loading="levelsLoading"
                  :disabled="!selectedMapId"
                  clearable
                  size="medium"
                  style="width: 160px"
                  @update:value="handleLevelChange"
                />
              </div>
            </n-space>
          </div>
          <div class="filter-right">
            <n-space :size="12">
              <n-button size="medium" @click="handleRefresh" :loading="loading" type="primary">
                <template #icon>
                  <n-icon><RefreshOutline /></n-icon>
                </template>
                刷新数据
              </n-button>
              <n-button size="medium" @click="handleReset" secondary>
                <template #icon>
                  <n-icon><CloseOutline /></n-icon>
                </template>
                重置筛选
              </n-button>
            </n-space>
          </div>
        </div>
      </n-card>
    </div>

    <!-- 主要内容区域 -->
    <div class="main-content">
      <!-- 加载状态 -->
      <div v-if="loading" class="loading-state">
        <n-spin size="large">
          <div class="loading-content">
            <n-icon size="48" class="loading-icon">
              <svg viewBox="0 0 24 24">
                <path fill="currentColor" d="M12,2A10,10 0 0,1 22,12A10,10 0 0,1 12,22A10,10 0 0,1 2,12A10,10 0 0,1 12,2M12,4A8,8 0 0,0 4,12A8,8 0 0,0 12,20A8,8 0 0,0 20,12A8,8 0 0,0 12,4M12,6A6,6 0 0,1 18,12A6,6 0 0,1 12,18A6,6 0 0,1 6,12A6,6 0 0,1 12,6M12,8A4,4 0 0,0 8,12A4,4 0 0,0 12,16A4,4 0 0,0 16,12A4,4 0 0,0 12,8Z"/>
              </svg>
            </n-icon>
            <div class="loading-text">
              <h3>正在加载战术装备数据</h3>
              <p>请稍候，正在为您准备最优配置方案...</p>
            </div>
          </div>
        </n-spin>
      </div>

      <!-- 错误状态 -->
      <div v-else-if="error" class="error-state">
        <n-result status="error" title="数据加载失败">
          <template #description>
            <div class="error-description">
              {{ error }}
            </div>
          </template>
          <template #footer>
            <n-button type="primary" @click="handleRefresh">
              <template #icon>
                <n-icon><RefreshOutline /></n-icon>
              </template>
              重新加载
            </n-button>
          </template>
        </n-result>
      </div>

      <!-- 空状态 -->
      <div v-else-if="currentLevelLoadouts.length === 0" class="empty-state">
        <n-empty size="large" description="暂无装备配置数据">
          <template #icon>
            <n-icon size="64">
              <svg viewBox="0 0 24 24">
                <path fill="currentColor" d="M12,2A10,10 0 0,1 22,12A10,10 0 0,1 12,22A10,10 0 0,1 2,12A10,10 0 0,1 12,2M12,4A8,8 0 0,0 4,12A8,8 0 0,0 12,20A8,8 0 0,0 20,12A8,8 0 0,0 12,4M12,6A6,6 0 0,1 18,12A6,6 0 0,1 12,18A6,6 0 0,1 6,12A6,6 0 0,1 12,6M12,8A4,4 0 0,0 8,12A4,4 0 0,0 12,16A4,4 0 0,0 16,12A4,4 0 0,0 12,8Z"/>
              </svg>
            </n-icon>
          </template>
          <template #extra>
            <n-space>
              <n-button type="primary" @click="handleRefresh">
                <template #icon>
                  <n-icon><RefreshOutline /></n-icon>
                </template>
                刷新数据
              </n-button>
              <n-button @click="handleReset">
                <template #icon>
                  <n-icon><CloseOutline /></n-icon>
                </template>
                重置筛选
              </n-button>
            </n-space>
          </template>
        </n-empty>
      </div>

      <!-- 装备配置列表 -->
      <div v-else class="loadouts-container">
        <div v-for="loadoutGroup in currentLevelLoadouts" :key="loadoutGroup.key" class="loadout-group">
          <!-- 组标题 -->
          <div class="group-header">
            <div class="group-title">
              <n-icon size="18" class="group-icon">
                <svg viewBox="0 0 24 24">
                  <path fill="currentColor" d="M12,2A10,10 0 0,1 22,12A10,10 0 0,1 12,22A10,10 0 0,1 2,12A10,10 0 0,1 12,2M12,4A8,8 0 0,0 4,12A8,8 0 0,0 12,20A8,8 0 0,0 20,12A8,8 0 0,0 12,4M12,6A6,6 0 0,1 18,12A6,6 0 0,1 12,18A6,6 0 0,1 6,12A6,6 0 0,1 12,6M12,8A4,4 0 0,0 8,12A4,4 0 0,0 12,16A4,4 0 0,0 16,12A4,4 0 0,0 12,8Z"/>
                </svg>
              </n-icon>
              <h3>{{ loadoutGroup.data?.map_context?.map_name || getMapName(loadoutGroup.map_id) }} - {{ loadoutGroup.data?.map_context?.level_name || getLevelName(loadoutGroup.level) }}</h3>
            </div>
            <div class="group-meta">
              <n-tag type="info" :bordered="false" size="small">
                <template #icon>
                  <n-icon><ListOutline /></n-icon>
                </template>
                {{ loadoutGroup.data?.total_count || 0 }} 个配置
              </n-tag>
              <n-tag v-if="loadoutGroup.data?.map_context?.budget" type="success" :bordered="false" size="small">
                <template #icon>
                  <n-icon><WalletOutline /></n-icon>
                </template>
                预算: {{ formatPrice(loadoutGroup.data.map_context.budget) }}
              </n-tag>
            </div>
          </div>

          <!-- 装备配置卡片网格 -->
          <div class="loadouts-grid">
            <div
              v-for="(loadout, index) in loadoutGroup.data?.loadouts || []"
              :key="index"
              class="loadout-card"
            >
              <!-- 卡片头部 -->
              <div class="card-header">
                <div class="card-title">
                  <span class="loadout-index">#{{ index + 1 }}</span>
                  <n-tag
                    :type="loadout.budget_ratio > 1 ? 'error' : loadout.budget_ratio > 0.95 ? 'warning' : 'success'"
                    size="small"
                    :bordered="false"
                  >
                    {{ (loadout.budget_ratio * 100).toFixed(1) }}%
                  </n-tag>
                </div>
                <div class="card-cost">{{ formatPrice(loadout.total_cost) }}</div>
              </div>

              <!-- 武器区域 -->
              <div v-if="loadout.weapon" class="weapon-section">
                <div class="weapon-card">
                  <img :src="loadout.weapon.pic" :alt="loadout.weapon.name" :class="['weapon-icon', `grade-${loadout.weapon.grade}`]" />
                  <div class="weapon-info">
                    <div class="weapon-name">{{ loadout.weapon.name }}</div>
                    <div class="weapon-price">{{ formatPrice(loadout.weapon.price) }}</div>
                    <n-tag :type="getGradeType(loadout.weapon.grade)" size="small" :bordered="false">
                      {{ getGradeName(loadout.weapon.grade) }}
                    </n-tag>
                  </div>
                </div>

                <!-- 配件区域 -->
                <div v-if="loadout.accessories && loadout.accessories.length > 0" class="accessories-section">
                  <div class="section-title">配件 ({{ loadout.accessories.length }})</div>
                  <div class="accessories-grid">
                    <div
                      v-for="(accessory, accIndex) in loadout.accessories"
                      :key="accIndex"
                      class="accessory-card"
                    >
                      <img :src="accessory.pic" :alt="accessory.name" :class="['accessory-icon', `grade-${accessory.grade}`]" />
                      <div class="accessory-info">
                        <div class="accessory-name">{{ accessory.name }}</div>
                        <div class="accessory-price">{{ formatPrice(accessory.price) }}</div>
                      </div>
                    </div>
                  </div>
                </div>
              </div>

              <!-- 防护装备网格 -->
              <div class="protection-grid">
                <div v-if="loadout.helmet" class="protection-item">
                  <img :src="loadout.helmet.pic" :alt="loadout.helmet.name" :class="['protection-icon', `grade-${loadout.helmet.grade}`]" />
                  <div class="protection-info">
                    <div class="protection-name">{{ loadout.helmet.name }}</div>
                    <div class="protection-price">{{ formatPrice(loadout.helmet.price) }}</div>
                  </div>
                </div>

                <div v-if="loadout.armor" class="protection-item">
                  <img :src="loadout.armor.pic" :alt="loadout.armor.name" :class="['protection-icon', `grade-${loadout.armor.grade}`]" />
                  <div class="protection-info">
                    <div class="protection-name">{{ loadout.armor.name }}</div>
                    <div class="protection-price">{{ formatPrice(loadout.armor.price) }}</div>
                  </div>
                </div>

                <div v-if="loadout.backpack" class="protection-item">
                  <img :src="loadout.backpack.pic" :alt="loadout.backpack.name" :class="['protection-icon', `grade-${loadout.backpack.grade}`]" />
                  <div class="protection-info">
                    <div class="protection-name">{{ loadout.backpack.name }}</div>
                    <div class="protection-price">{{ formatPrice(loadout.backpack.price) }}</div>
                  </div>
                </div>

                <div v-if="loadout.chest_rig" class="protection-item">
                  <img :src="loadout.chest_rig.pic" :alt="loadout.chest_rig.name" :class="['protection-icon', `grade-${loadout.chest_rig.grade}`]" />
                  <div class="protection-info">
                    <div class="protection-name">{{ loadout.chest_rig.name }}</div>
                    <div class="protection-price">{{ formatPrice(loadout.chest_rig.price) }}</div>
                  </div>
                </div>
              </div>

              <!-- 卡片底部时间 -->
              <div class="card-footer">
                <div class="card-time">{{ formatTime(loadout.generated_at) }}</div>
              </div>
            </div>
          </div>
        </div>
      </div>
    </div>
  </div>
</template>

<script lang="ts" setup>
import { ref, computed, onMounted, watch } from 'vue'
import { RefreshOutline, CloseOutline, ListOutline, WalletOutline } from '@vicons/ionicons5'
import { useTacticalStore } from '@/stores/tactical'

// 状态管理
const tacticalStore = useTacticalStore()

// 计算属性
const loading = computed(() => tacticalStore.loading)
const mapsLoading = computed(() => tacticalStore.mapsLoading)
const levelsLoading = computed(() => tacticalStore.levelsLoading)
const error = computed(() => tacticalStore.error)
const maps = computed(() => tacticalStore.maps)
const levels = computed(() => tacticalStore.levels)
const currentLevelLoadouts = computed(() => tacticalStore.currentLevelLoadouts)
const totalLoadouts = computed(() => tacticalStore.totalLoadouts)
const validLoadouts = computed(() => tacticalStore.validLoadouts)
const averageValue = computed(() => tacticalStore.averageValue)

// 本地状态
const selectedMapId = ref('')
const selectedLevel = ref('')

// 选项
const mapOptions = computed(() => 
  maps.value.map(mapId => ({
    label: getMapName(mapId),
    value: mapId
  }))
)

const levelOptions = computed(() => 
  levels.value.map(level => ({
    label: getLevelName(level),
    value: level
  }))
)

// 生命周期
onMounted(async () => {
  await tacticalStore.fetchMaps()
  await tacticalStore.fetchLoadouts()
})

// 监听筛选条件变化
watch(selectedMapId, (newMapId) => {
  tacticalStore.updateFilters({ map_id: newMapId || '' })
})

watch(selectedLevel, (newLevel) => {
  tacticalStore.updateFilters({ level: newLevel || '' })
})

// 事件处理
const handleMapChange = (mapId: string | null) => {
  selectedMapId.value = mapId || ''
  selectedLevel.value = ''
}

const handleLevelChange = (level: string | null) => {
  selectedLevel.value = level || ''
}

const handleRefresh = () => {
  tacticalStore.fetchLoadouts()
}

const handleReset = () => {
  selectedMapId.value = ''
  selectedLevel.value = ''
  tacticalStore.resetFilters()
}

// 辅助函数
const getMapName = (mapId: string) => {
  const mapNames: Record<string, string> = {
    'dam': '大坝',
    'longbow': '长弓',
    'prison': '监狱',
    'baksh': '巴克什',
    'space_base': '航天基地'
  }
  return mapNames[mapId] || mapId
}

const getLevelName = (level: string) => {
  const levelNames: Record<string, string> = {
    '绝密': '绝密等级',
    '机密': '机密等级',
    '标准': '标准等级',
    '高级': '高级等级',
    '终夜': '终夜等级',
    '终夜大坝': '终夜大坝专用'
  }
  return levelNames[level] || level
}

// 格式化价格
const formatPrice = (price: number) => {
  return price.toLocaleString() + ' 哈夫币'
}

// 格式化时间
const formatTime = (timeStr: string) => {
  if (!timeStr) return ''
  const date = new Date(timeStr)
  return date.toLocaleString('zh-CN', {
    year: 'numeric',
    month: '2-digit',
    day: '2-digit',
    hour: '2-digit',
    minute: '2-digit'
  })
}

// 获取等级类型
const getGradeType = (grade: number) => {
  const gradeTypes: Record<number, string> = {
    0: 'default',
    1: 'info',
    2: 'success',
    3: 'warning',
    4: 'error',
    5: 'error'
  }
  return gradeTypes[grade] || 'default'
}

// 获取等级名称
const getGradeName = (grade: number) => {
  const gradeNames: Record<number, string> = {
    0: '特殊',
    1: '1级',
    2: '2级',
    3: '3级',
    4: '4级',
    5: '5级'
  }
  return gradeNames[grade] || `${grade}级`
}
</script>

<style scoped>
.tactical-loadouts-page {
  min-height: 100vh;
  background: linear-gradient(135deg, var(--n-color-target) 0%, var(--n-card-color) 100%);
  padding: 0;
}

/* 页面标题栏 */
.page-header {
  background: var(--n-card-color);
  border-bottom: 1px solid var(--n-border-color);
  padding: 16px 0;
  box-shadow: 0 1px 8px rgba(0, 0, 0, 0.08);
}

.header-content {
  margin: 0 auto;
  padding: 0 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
}

.header-left {
  flex: 1;
}

.title-section {
  display: flex;
  align-items: center;
  gap: 12px;
}

.title-icon {
  color: var(--n-primary-color);
  background: var(--n-primary-color-hover);
  padding: 6px;
  border-radius: 8px;
}

.title-text h1 {
  margin: 0;
  font-size: 24px;
  font-weight: 600;
  color: var(--n-text-color-1);
  line-height: 1.2;
}

.title-text p {
  margin: 2px 0 0 0;
  font-size: 13px;
  color: var(--n-text-color-3);
  font-weight: 400;
}

.header-right {
  flex-shrink: 0;
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 16px;
}

.stat-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
}

.stat-value {
  font-size: 20px;
  font-weight: 600;
  color: var(--n-primary-color);
  line-height: 1.2;
}

.stat-label {
  font-size: 11px;
  color: var(--n-text-color-3);
  margin-top: 2px;
  font-weight: 400;
}

/* 筛选控制栏 */
.filter-panel {
  padding: 16px 20px;
  margin: 0 auto;
}

.filter-card {
  border-radius: 8px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
  border: 1px solid var(--n-border-color);
}

.filter-content {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  gap: 20px;
}

.filter-left {
  flex: 1;
}

.filter-item {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.filter-label {
  font-size: 12px;
  font-weight: 500;
  color: var(--n-text-color-2);
}

.filter-right {
  flex-shrink: 0;
}

/* 主要内容区域 */
.main-content {
  margin: 0 auto;
  padding: 0 20px 20px;
}

/* 状态页面 */
.loading-state {
  display: flex;
  justify-content: center;
  align-items: center;
  min-height: 400px;
  padding: 60px 0;
}

.loading-content {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 24px;
  text-align: center;
}

.loading-icon {
  color: var(--n-primary-color);
  animation: spin 2s linear infinite;
}

@keyframes spin {
  from { transform: rotate(0deg); }
  to { transform: rotate(360deg); }
}

.loading-text h3 {
  margin: 0;
  font-size: 20px;
  color: var(--n-text-color-1);
  font-weight: 600;
}

.loading-text p {
  margin: 8px 0 0 0;
  font-size: 14px;
  color: var(--n-text-color-3);
}

.error-state {
  padding: 60px 0;
}

.error-description {
  font-size: 16px;
  color: var(--n-text-color-2);
  margin-top: 8px;
}

.empty-state {
  padding: 60px 0;
}

/* 装备配置列表 */
.loadouts-container {
  display: flex;
  flex-direction: column;
  gap: 24px;
}

.loadout-group {
  background: var(--n-card-color);
  border-radius: 8px;
  padding: 16px;
  border: 1px solid var(--n-border-color);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.04);
}

.group-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--n-border-color);
}

.group-title {
  display: flex;
  align-items: center;
  gap: 8px;
}

.group-icon {
  color: var(--n-primary-color);
  background: var(--n-primary-color-hover);
  padding: 3px;
  border-radius: 6px;
}

.group-title h3 {
  margin: 0;
  font-size: 16px;
  font-weight: 600;
  color: var(--n-text-color-1);
}

.group-meta {
  display: flex;
  align-items: center;
  gap: 8px;
}

/* 装备卡片网格 */
.loadouts-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(400px, 1fr));
  gap: 20px;
}

.loadout-card {
  background: var(--n-body-color);
  border: 1px solid var(--n-border-color);
  border-radius: 8px;
  padding: 12px;
  transition: all 0.2s ease;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.loadout-card:hover {
  border-color: var(--n-primary-color-hover);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
  transform: translateY(-2px);
}

/* 卡片头部 */
.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--n-border-color);
}

.card-title {
  display: flex;
  align-items: center;
  gap: 8px;
}

.loadout-index {
  font-size: 16px;
  font-weight: 600;
  color: var(--n-primary-color);
}

.card-cost {
  font-size: 16px;
  font-weight: 600;
  color: var(--n-text-color-1);
}

/* 武器区域 */
.weapon-section {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.weapon-card {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px;
  background: var(--n-card-color);
  border-radius: 6px;
  border-left: 3px solid var(--n-error-color);
}

.weapon-icon {
  width: 56px;
  height: 56px;
  object-fit: contain;
  border-radius: 6px;
  background: var(--n-body-color);
  border: 2px solid;
  padding: 2px;
}

.weapon-info {
  flex: 1;
  min-width: 0;
}

.weapon-name {
  font-size: 15px;
  font-weight: 600;
  color: var(--n-text-color-1);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-bottom: 3px;
}

.weapon-price {
  font-size: 13px;
  color: var(--n-text-color-3);
}

/* 配件区域 */
.accessories-section {
  margin-top: 8px;
}

.section-title {
  font-size: 12px;
  font-weight: 600;
  color: var(--n-text-color-2);
  margin-bottom: 6px;
  padding-left: 4px;
  border-left: 3px solid var(--n-info-color);
}

/* 配件横向网格 */
.accessories-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
  gap: 6px;
}

.accessory-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 6px;
  background: var(--n-card-color);
  border-radius: 6px;
  border: 1px solid var(--n-border-color);
  text-align: center;
  transition: all 0.2s ease;
}

.accessory-card:hover {
  border-color: var(--n-info-color);
  transform: translateY(-1px);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.accessory-icon {
  width: 36px;
  height: 36px;
  object-fit: contain;
  border-radius: 4px;
  background: var(--n-body-color);
  border: 2px solid;
  padding: 2px;
}

.accessory-info {
  width: 100%;
  min-width: 0;
}

.accessory-name {
  font-size: 11px;
  font-weight: 500;
  color: var(--n-text-color-1);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-bottom: 2px;
}

.accessory-price {
  font-size: 10px;
  color: var(--n-text-color-3);
}

/* 防护装备网格 */
.protection-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 6px;
}

.protection-item {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px;
  background: var(--n-card-color);
  border-radius: 4px;
  border-left: 2px solid var(--n-success-color);
}

.protection-icon {
  width: 40px;
  height: 40px;
  object-fit: contain;
  border-radius: 4px;
  background: var(--n-body-color);
  border: 2px solid;
  padding: 2px;
}

.protection-info {
  flex: 1;
  min-width: 0;
}

.protection-name {
  font-size: 13px;
  font-weight: 500;
  color: var(--n-text-color-1);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.protection-price {
  font-size: 12px;
  color: var(--n-text-color-3);
  margin-top: 2px;
}

/* 卡片底部 */
.card-footer {
  padding-top: 8px;
  border-top: 1px solid var(--n-border-color);
  text-align: center;
}

.card-time {
  font-size: 12px;
  color: var(--n-text-color-3);
}

/* 等级边框颜色 */
.grade-0 {
  border-color: #8b5cf6 !important; /* 紫色 - 特殊 */
  box-shadow: 0 0 8px rgba(139, 92, 246, 0.3);
}

.grade-1 {
  border-color: #6b7280 !important; /* 灰色 - 1级 */
  box-shadow: 0 0 6px rgba(107, 114, 128, 0.2);
}

.grade-2 {
  border-color: #10b981 !important; /* 绿色 - 2级 */
  box-shadow: 0 0 6px rgba(16, 185, 129, 0.3);
}

.grade-3 {
  border-color: #3b82f6 !important; /* 蓝色 - 3级 */
  box-shadow: 0 0 8px rgba(59, 130, 246, 0.3);
}

.grade-4 {
  border-color: #f59e0b !important; /* 橙色 - 4级 */
  box-shadow: 0 0 8px rgba(245, 158, 11, 0.3);
}

.grade-5 {
  border-color: #ef4444 !important; /* 红色 - 5级 */
  box-shadow: 0 0 10px rgba(239, 68, 68, 0.4);
}

/* 响应式设计 */
@media (max-width: 768px) {
  .header-content {
    flex-direction: column;
    align-items: flex-start;
    gap: 16px;
  }

  .stats-grid {
    grid-template-columns: repeat(3, 1fr);
    gap: 12px;
  }

  .stat-value {
    font-size: 18px;
  }

  .filter-content {
    flex-direction: column;
    gap: 12px;
  }

  .filter-left {
    width: 100%;
  }

  .filter-left .n-space {
    flex-direction: column;
    width: 100%;
  }

  .filter-item {
    width: 100%;
  }

  .filter-item .n-select {
    width: 100% !important;
  }

  .group-header {
    flex-direction: column;
    align-items: flex-start;
    gap: 8px;
  }

  .group-meta {
    flex-wrap: wrap;
  }

  .loadouts-grid {
    grid-template-columns: 1fr;
  }

  .accessories-grid {
    grid-template-columns: repeat(2, 1fr);
  }

  .protection-grid {
    grid-template-columns: 1fr;
  }

  .weapon-name,
  .accessory-name,
  .protection-name {
    font-size: 12px;
  }
}

@media (max-width: 480px) {
  .tactical-loadouts-page {
    padding: 0;
  }

  .page-header {
    padding: 12px 0;
  }

  .header-content {
    padding: 0 16px;
  }

  .title-text h1 {
    font-size: 20px;
  }

  .filter-panel {
    padding: 12px 16px;
  }

  .main-content {
    padding: 0 16px 16px;
  }

  .loadout-group {
    padding: 12px;
  }

  .stats-grid {
    grid-template-columns: 1fr;
    gap: 8px;
  }

  .loadouts-grid {
    grid-template-columns: 1fr;
    gap: 12px;
  }

  .weapon-icon {
    width: 48px;
    height: 48px;
  }

  .accessory-icon {
    width: 32px;
    height: 32px;
  }

  .accessories-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 4px;
  }

  .accessory-name {
    font-size: 10px;
  }

  .accessory-price {
    font-size: 9px;
  }

  .protection-icon {
    width: 36px;
    height: 36px;
  }

  .card-cost {
    font-size: 14px;
  }

  .weapon-name,
  .accessory-name,
  .protection-name {
    font-size: 12px;
  }

  .weapon-price,
  .accessory-price,
  .protection-price {
    font-size: 11px;
  }
}


</style>